
		<meta charset="utf-8" />

<?php

   include_once('dbConn.php');
	connect();
//使用$_POST数组获取表单中输入的数据
session_start();
$name=$_SESSION['adminname'];
$sql0="select * from admins where adminname='$name'";
$rs0=mysql_query($sql0);
$row0=mysql_fetch_assoc($rs0);
$uploadadmin=$row0["adminid"];

  $videoname = trim($_POST['videoname']);  
  $tid = $_POST['tid'];
  $typename = $_POST['typename'];
//$uploadadmin = $_POST['uploadadmin'];
  $intro = $_POST['intro'];
  $pic = $_POST['pic'];
  $address = $_POST['address'];


//2.上传文件判断类型
	$allowtype=array("jpg","jpeg","png","gif","bmp","flv");
	$arr=explode(".",$_FILES["pic"]["name"]);
	$suffix=$arr[count($arr)-1];
	if(! in_array($suffix,$allowtype)){
		echo "文件类型错误！";
		exit;
	}else{
	echo"<br>海报已上传<br>";
	}
//3.拷贝文件
	$filepath="./images/";
	$randname=date("YmdHis").rand(100,999).".".$suffix;
	move_uploaded_file($_FILES["pic"]["tmp_name"],$filepath.$randname);


  //插入数据库
    $sql="insert into videos(vid,videoname,tid,pic,intro,uploaddate,uploadadmin,hittimes,downtimes,address) 
    values (0,'$videoname','$tid','$randname','$intro',NOW(),'$uploadadmin','0','0','$address')";
    echo $sql.'<br/>';
   //执行SQL语句
  $result = mysql_query($sql) or die('插入失败！'.mysql_error());
  //判断是否插入成功
  $num = mysql_affected_rows();
  if($num!=1){
  	echo "视频添加失败，2秒后返回视频信息页！<br/>";
  	header("refresh:2;url='video_list.php'");     
  }else{	
	echo "视频信息添加成功，2秒后返回视频信息页！<br/>";  
	header("refresh:2;url='video_list.php'");   
  } 
  //关闭数据库
  mysql_close();  

?>